<?php
class ErrorController extends ImpSoft_Controller_Action {

    public function errorAction() {
	
        $errors = $this->_getParam('error_handler');
		
		if ($errors->exception instanceof ImpSoft_Exception_NotFound) {
			//@todo not sure if I like this... there could be a better way...
			$errors->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER;
		}
		
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
                break;
            default:
				// Some other kind of exception was thrown...
                break;
        }
		
		$this->view->exception = $errors->exception;
	
    }
	
	public function deniedAction() {
	
		// denied... beeeyotch!
		// @todo: grab the page they WANTED to go to and store it so that when
		// they log back in they are sent to the right place
		if (Zend_Auth::getInstance()->hasIdentity()) {
			// show page saying they don't have access
		} else {
			// send them to the login page if they aren't logged in
			$this->goToRoute("auth_login");
		}
	
	}

}